package com.itheima.spring_123_06.controller;

import com.itheima.spring_123_06.pojo.User;
import com.itheima.spring_123_06.service.Userservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private Userservice userservice;

    @RequestMapping("/findUser")
    public List<User> findUser() {
        System.out.println("findUser 执行了...");
        return userservice.finduser();


    }

    @Autowired
    private RedisTemplate redisTemplate;

    @RequestMapping("/set")
    public String set(String key, String value) {
        redisTemplate.boundValueOps(key).set(value);
        return "set..";
    }

    @RequestMapping("/get")
    public String get(String key) {

        return (String) redisTemplate.boundValueOps(key).get();

    }
}
